package top.soulblack.purchasesale.service;

import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.mapper.GoodsMaterialMapper;
import top.soulblack.purchasesale.model.GoodsBrand;
import top.soulblack.purchasesale.model.GoodsMaterial;

import javax.annotation.Resource;
import java.util.List;

/**
 * create by 小川
 */

@Service
public class GoodsMaterialService {

    @Resource
    private GoodsMaterialMapper goodsMaterialMapper;

    public List<GoodsMaterial> selectAll(){
        return goodsMaterialMapper.selectAll();
    }

    public void addMaterial(GoodsMaterial goodsMaterial){
        goodsMaterialMapper.addMaterial(goodsMaterial);
        return;
    }

    public boolean existMaterial(String name){
        int num  = goodsMaterialMapper.existMaterial(name);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean deleteMaterial(int materialId) {
        int num = goodsMaterialMapper.deleteById(materialId);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean updateMaterial(GoodsMaterial goodsMaterial) {
        int num = goodsMaterialMapper.updateByPrimaryKey(goodsMaterial);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean selectMaterial(Integer materialId){
        List<Integer> num = goodsMaterialMapper.selectMaterial(materialId);
        if (num  != null) {
            return true;
        }
        return false;
    }
}
